import request from '@/utils/http'

interface BaseResponse<T = any> {
  code: string
  msg: string
  data: T
}

export function getMaterialGroup(params: object) {
  return request.get<BaseResponse>({
    url: '/materialCenter/getGroupList',
    params
  })
}

export function addMaterialGroup(data: object) {
  return request.post<BaseResponse>({
    url: '/materialCenter/addGroup',
    data
  })
}

export function delMaterialGroup(ids: string) {
  return request.del<BaseResponse>({
    url: `/materialCenter/delGroup/${ids}`
  })
}

export function editMaterialGroup(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `/materialCenter/updateGroup/${id}`,
    data
  })
}

export function getFilePage(params: object) {
  return request.get<BaseResponse>({
    url: '/materialCenter/getFilePage',
    params
  })
}

export function addListFile(data: object) {
  return request.post<BaseResponse>({
    url: '/materialCenter/addListFile',
    data
  })
}

export function delFile(ids: string) {
  return request.del<BaseResponse>({
    url: `/materialCenter/delFile/${ids}`
  })
}

export function editFile(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `/materialCenter/updateFile/${id}`,
    data
  })
}

export function batchMoveGroup(data: object) {
  return request.post<BaseResponse>({
    url: '/materialCenter/addToGroup',
    data
  })
}

export function addDiyPage(data: object) {
  return request.post<BaseResponse>({
    url: '/diyPage/add',
    data
  })
}

export function editDiyPage(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `/diyPage/update/${id}`,
    data
  })
}

export function getPageList(params: object) {
  return request.get<BaseResponse>({
    url: '/diyPage/getPage',
    params
  })
}

export function delPage(ids: string) {
  return request.del<BaseResponse>({
    url: `/diyPage/del/${ids}`
  })
}

export function getTemplateList(params: object) {
  return request.get<BaseResponse>({
    url: '/diyTemplate/getPage',
    params
  })
}

export function getPageDetail(id: string) {
  return request.get<BaseResponse>({
    url: `/diyPage/${id}/form`
  })
}

export function getTemplateDetail(id: string) {
  return request.get<BaseResponse>({
    url: `/diyTemplate/${id}/form`
  })
}

export function editPageType(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `/diyPage/updateStat/${id}`,
    data
  })
}

export function copyPageType(data: object) {
  return request.post<BaseResponse>({
    url: `/diyPage/Copy`,
    data
  })
}

export function getComponentBindData(url: string, data: object) {
  return request.post<BaseResponse>({
    url,
    data
  })
}

export function getLinkList(params: object) {
  return request.get<BaseResponse>({
    url: '/diyMenu/getRoutePath',
    params
  })
}

export function getTabBarList(params: object) {
  return request.get<BaseResponse>({
    url: '/diyTemplate/getFooter',
    params
  })
}

export function addTabBar(data: object) {
  return request.post<BaseResponse>({
    url: '/diyTemplate/add',
    data
  })
}

export function editTabBar(id: string | undefined, data: object) {
  return request.put<BaseResponse>({
    url: `/diyTemplate/update/${id}`,
    data
  })
}

export function getSpecialQuestion(data: object) {
  return request.post<BaseResponse>({
    url: '/wmpExam/getPartQuestion',
    data
  })
}
//获取文章分组信息
export function getArticleGroup() {
  return request.get<BaseResponse>({
    url: '/StoreArticle/getGroupList',
    // params: data
  })
}
//新增分组
export function addArticleGroup(data: object) {
  return request.post<BaseResponse>({
    url: 'StoreArticle/addGroup',
    data
  })
}
//编辑分组
export function editArticleGroup(id: string, data: object) {
  return request.put<BaseResponse>({
    url: `StoreArticle/updateGroup/${id}`,
    data
  })
}
//删除分组
export function delArticleGroup(ids: string) {
  return request.del<BaseResponse>({
    url: `StoreArticle/delGroup/${ids}`
  })
}
//获取单个基础信息
export function getBasicInfo(data: object) {
  return request.get<BaseResponse>({
    url: `sdkKey/getOne`,
    params: data
  })
}
//获取全部基础信息
export function getAllBasicInfo() {
  return request.get<BaseResponse>({
    url: `sdkKey/getAll`
  })
}
//新增或更新基础信息
export function addBasicInfo(data: object) {
  return request.post<BaseResponse>({
    url: `sdkKey/addOrUpate`,
    data
  })
}
